using IQIGame.Onigao.GamePlay;

namespace IQIGame.Onigao.Logic
{
    /// <summary>
    /// 实体状态触发器（陷阱），当视图层在实体触发范围内时，如果实体拥有多种状态，会通知逻辑层当前实体状态，从而根据参数触发相应服务
    /// 参数：触发服务的状态
    /// </summary>
    public class TrigEntityState : BaseServiceTrigger
    {
        public override bool OnTrigger(LevelPlayer player, object dynamicParam, TrigValueTypeParam dynamicValueTypePram)
        {
            var config = _paramConfig as TrigParamEntityState;
            if (config == null)
            {
                LogicLog.LogError($"触发器[{nameof(TrigEntityState)}]参数错误。");
                return false;
            }
            int state = dynamicValueTypePram.param1;
            if (state == config.requireState)
            {
                return base.OnTrigger(player, dynamicParam, dynamicValueTypePram);
            }
            return false;
        }
    }
}
